
import json
from pathlib import Path

# 从文件中导入数据，转为dict
def txt_to_dict(filepath: str) -> dict:
    try:
        with open(filepath, 'r', encoding='utf-8') as fs:
            s = fs.read()
            s = s.replace('\t', '')
            s = s.replace('\n', '')
            s = s.replace(',}', '}')
            return json.loads(s)
    except IOError as e:
        print(e)

def main():
    main_path = Path(__file__).resolve().parent
    access_token_path = main_path.joinpath('数据源', 'access_tokens.txt')
    access_tokens = txt_to_dict(access_token_path)
    gs_webhooks = ["https://oapi.dingtalk.com/robot/send?access_token=" + access_token for access_token in access_tokens['GS']]
    print(gs_webhooks)


if __name__ == '__main__':
    main()



